#include<iostream>
using namespace std;
int test(char arr[], int s, int WS,int ws,int Chu)
{
	int count[10] = { 0 };
	char Arr[50] = { NULL };
	int local[10][20] = { NULL };
	for (int i = 0; i < s; i++)
	{
		//根据递归次数依次取 个 十 百 ...位数
		count[ (arr[i]/Chu) % WS ]++;
		//将元素储存到下标数组
		for (int b = 0; b < s; b++)
		{
			if (local[(arr[i] / Chu) % WS][b] == 0)
			{
				local[(arr[i] / Chu) % WS][b] = arr[i];
				break;
			}
		}
	}
	//输入桶
	for (int i = 0,L=0; i < 10; i++)
	{
		int temp = count[i];
		if (temp != 0)
		{
			for (int b = 0; b < temp; b++)
			{
				Arr[L] = local[i][b];     //排序后的桶
				L++;
			}
		}
	}
	ws--;
	Chu *= 10;
	if (ws == 0)                 //终止条件  当位数等于0
	{
		cout << "排序后的数组：" << endl;
		for (int i = 0; i < s; i++)
		{
			cout << Arr[i] << " ";
		}
		cout << endl;
		return 0;
	}
	return test(Arr, s, WS, ws,Chu);
}
void FindBest(char arr[], int s)
{

	char max=NULL ;
	//寻找最大值
	for (int i = 0; i < s; i++)
	{
		if (arr[i] > max)
		{
			max = arr[i];
		}
	}
	int ws = 0;
	while (max != 0)       //求位数
	{
		max /= 10;
		ws++;
	}
	char array[50] = { NULL };
	int WS = 10;      
	int Chu = 1;   //除数
	test(arr, s, WS, ws,Chu);
}
int main()
{
	int s_arr = 0;
	cout << "输入数组的大小:" << endl;
	cin >> s_arr;
	char arr[50];
	cout << "依次输入数组元素：" << endl;
	for (int i = 0; i < s_arr; i++)
	{
		char temp = 0;
		cin >> temp;
		arr[i] = temp;
	}
	FindBest(arr, s_arr);
	return 0;
}